<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="panel-heading" style="text-align: right">
        <button class="btn btn-default" id="StorageCell_add">提交</button>
        <button type="button" class="btn btn-default"><a href="javascript:history.back()"
                                                         style="color: black">返回</a></button>
    </div>
    <div class="panel panel-default">
        <form id="module_form" class="form-horizontal">
            <div class="panel-heading">
                <div class="h4" align="center">出库调度单</div>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">出库单编号</label>
                        <div class="col-sm-8">
                            <input type="text" name="payId" id="payId"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">产品编号</label>
                        <div class="col-sm-8 ">
                            <input type="text" name="productId" id="productId"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">产品名称</label>
                        <div class="col-sm-8 ">
                            <input type="text" name="productName" id="productName"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">成本单价</label>
                        <div class="col-sm-8">
                            <input type="text" name="costPrice" id="costPrice"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">当前库存数</label>
                    <div class="col-sm-8">
                        <input type="text" name="amount1" id="amount1"
                               class="form-control text_bottom_border" style="background-color: #FFFFFF"
                               value="">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">本次出库数量</label>
                    <div class="col-sm-8">
                        <input type="text" name="gatheredAmount" id="gatheredAmount"
                               class="form-control text_bottom_border" style="background-color: #FFFFFF"
                               value="">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">登记人</label>
                    <div class="col-sm-8">
                        <input type="text" name="register" id="register"
                               class="form-control text_bottom_border" style="background-color: #FFFFFF" readonly
                               value="">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">登记时间</label>
                    <div class="col-sm-8">
                        <input type="text" name="registerTime" id="registerTime"
                               class="form-control text_bottom_border" style="background-color: #FFFFFF" readonly
                               value="">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">应出库数:</label>
                    <div class="col-sm-8">
                        <input class="form-control" id="amount" name="amount"
                               style="background-color: #FFFFFF" readonly>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">已出库数</label>
                    <div class="col-sm-8">
                        <input class="form-control" id="paidAmount" name="paidAmount"
                               style="background-color: #FFFFFF" readonly>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<!--<script type="text/javascript" src="/js/index.js"></script>-->

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
    $(function () {
        let id = localStorage.getItem("id51")
        let id1 = localStorage.getItem("id52")
        $.post("/StoragePay/showById", {"id": id1}, function (res) {
            $("#payId").val(res.payId)
            $("#register").val(res.register)
            $("#registerTime").val(fortime1(res.registerTime))
        })
        $.post("/StoragePay/showById2", {"id": id}, function (res) {
            $("#productId").val(res.productId)
            $("#productName").val(res.productName)
            $("#costPrice").val(res.costPrice)
            $("#amount").val(res.amount)
            $("#paidAmount").val(res.paidAmount)

            $.post("/StorageCell/getgetOnebianhao", {"productId": res.productId}, function (res) {
                console.log(res)
                $("#amount1").val(res.amount)
            })
        })
    })

    function fortime1(w) {
        let date = new Date(w);
        let y = date.getFullYear();
        let m = date.getMonth() + 1;
        let d = date.getDate();
        let h = date.getHours();
        let mm = date.getMinutes();
        let s = date.getSeconds();
        return (y + '-' + add(m) + '-' + add(d) + ' ' + add(h) + ':' + add(mm) + ':' + add(s));
    }

    function add(m) {
        return m < 10 ? '0' + m : m
    }

    $("#StorageCell_add").click(function () {
        let hh = Number($("#gatheredAmount").val())
        let hh1 = Number($("#amount1").val())
        if (hh1 >= hh) {
            if ($("#gatheredAmount").val() == $("#amount").val()) {
                let id = localStorage.getItem("id52")
                let id1 = localStorage.getItem("id51")
                let gatheredAmount = $("#gatheredAmount").val()
                $.post("/StoragePay/updateTWO2", {
                    "id": id,
                    "id1": id1,
                    "gatheredAmount": gatheredAmount
                }, function (res) {
                    if (res == true) {
                        window.location = "/safe/draw_up_an_outboun_dordeUI"
                    } else {
                        alert("还有要调度")
                    }
                })

            } else {
                alert("应出库数不一致")
            }
        } else {
            alert("不能大于库存数量")
        }
    })
</script>
</body>
</html>